import { defineConfig } from 'umi';
import proxyConfig from './proxy';
import analyzeConfig from './analyze';
import themeConfig from './theme'; // antd 的主题

var prod = process.env.SERVER_ENV === 'prod';
var host = ''; // 搭配腾讯云的静态网站托管或cdn，配置生产的api域名

export default defineConfig({
  ignoreMomentLocale: true,
  nodeModulesTransform: {
    type: 'none',
  },
  cssLoader: {
    localsConvention: 'camelCase',
  },
  hash: true,
  title: '标题',
  history: {
    type: 'hash',
  },
  favicon: './favicon.ico',
  publicPath: './',
  define: {
    $HOST: prod ? host : '',
  },
  externals: {
    bizcharts: 'BizCharts',
    react: 'React',
    'react-dom': 'ReactDOM',
  }, // 通过cdn加载react，减少包大小
  scripts: [
    'https://unpkg.com/react@16.12.0/umd/react.production.min.js',
    'https://unpkg.com/react-dom@16.12.0/umd/react-dom.production.min.js',
    'https://unpkg.com/bizcharts@4.0.14/umd/BizCharts.min.js',
  ],
  ...themeConfig,
  ...proxyConfig,
  ...analyzeConfig,
});
